import java.io.*;

public class CloseStreamManually {
    public static void main(String[] args) {
        FileInputStream fis = null;
        
        try{
            // 打开一个到指定文件的连接，并读取数据
            fis = new FileInputStream("example.txt");
            
            int data;
            while ((data = fis.read()) != -1){
                System.out.print((char)data);
            }
        } catch (FileNotFoundException e) { 
            e.printStackTrace();
        } catch (IOException e) { 
            e.printStackTrace();  
        } finally {
            if(fis != null){    
                try{   
                    // 关闭输入流并释放与之关联的所有系统资源
                    fis.close();     
                }catch(IOException ioException){
                    ioException.printStackTrace();
                }
            }
        }
    }
}